home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-06-19 | 1.2 KB | 59 lines | [TEXT/MPS ] |
- #include <files.h>
- #include "rawdrive.h"
-
- rawdrive::rawdrive( const FSSpec& volume )
- {
- HParamBlockRec pb;
-
- pb.volumeParam.ioCompletion= 0;
- pb.volumeParam.ioNamePtr= 0;
- pb.volumeParam.ioVRefNum= volume.vRefNum;
- pb.volumeParam.ioVolIndex= -1;
- error = PBHGetVInfo( &pb, 0 );
-
- drive= pb.volumeParam.ioVDrvInfo;
- driver= pb.volumeParam.ioVDRefNum;
- }
-
- OSErr rawdrive::read( long position, void *buffer, uint32& amount )
- {
- if (iswrong())
- return whatiswrong();
-
- ParamBlockRec pb;
- pb.ioParam.ioCompletion= 0;
- pb.ioParam.ioVRefNum= drive;
- pb.ioParam.ioRefNum= driver;
- pb.ioParam.ioBuffer= (Ptr)buffer;
- pb.ioParam.ioReqCount= amount;
- pb.ioParam.ioPosMode= fsFromStart;
- pb.ioParam.ioPosOffset= position;
-
- OSErr readerror= PBReadSync(&pb);
-
- amount= pb.ioParam.ioActCount;
-
- return readerror;
- }
-
- OSErr rawdrive::write( long position, void *buffer, uint32& amount )
- {
- if (iswrong())
- return whatiswrong();
-
- ParamBlockRec pb;
- pb.ioParam.ioCompletion= 0;
- pb.ioParam.ioVRefNum= drive;
- pb.ioParam.ioRefNum= driver;
- pb.ioParam.ioBuffer= (Ptr)buffer;
- pb.ioParam.ioReqCount= amount;
- pb.ioParam.ioPosMode= fsFromStart;
- pb.ioParam.ioPosOffset= position;
-
- OSErr writeerror= PBWriteSync(&pb);
-
- amount= pb.ioParam.ioActCount;
-
- return writeerror;
- }
-